<?php
    //判断客户端是否提交了数据，如果提交了，就连接数据库，将接收到的数据保存进数据库中
    if($_POST){
        $data = array(
            'cname'   => $_POST['cname'],
            'ename'   => $_POST['ename'],
            'cimg'    => $_POST['cimg'],
            'corders' => $_POST['corders'],
        );

        //var_dump($data);
        //exit();

        //引入数据库操作类
        require './lib/common.class.php';
        $db = database();
        //插入数据
        $rst = $db->insert('category',$data);
        //var_dump($rst);
        header('Location:article_category_list.php');
        exit();
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="public/css/bootstrap.css">
    <script src="public/js/jquery.min.js" type="text/javascript"></script>
    <script src="public/js/bootstrap.js" type="text/javascript"></script>
    <title>修改文章分类页面</title>
    <style>
        body{
            padding-top: 70px;
        }
    </style>
</head>
<body>
    <nav class="navbar navbar-inverse navbar-fixed-top">
        <div class="container-fluid">
            <div class="navbar-header">
                <a href="#" class="navbar-brand" style="paddin-top:10px;">
                    <img src="public/img/g.jpg" alt="" style="max-height: 30px;">
                </a>
            </div>

            <div class="collapse navbar-collapse" id="bs-examp;e-navbar-collapse-l">
                    <ul class="nav navbar-nav">
                            <li><a href="article_category_list.php">文章分类</a></li>
                            <li><a href="article_list.php">文章列表</a></li>
                    </ul>
                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdpwn">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Sandy<span class="caret"></span></a>
                            <ul class="dropdown-menu">
                                <li><a href="#">用户中心</a></li>
                                <li><a href="#">退出</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
        </div>
    </nav>

    <div class="container">
        <form action="" method="post">
            <div class="form-group">
                <label for="">
                    分类名称
                </label>
                <input class="form-control" type="text" name="title" id="title" placeholder="请输入分类名称">
            </div>
            <div class="form-group">
                <label for="">
                    英文名称
                </label>
                <input type="text" name="sug" id="sug" class="form-control" placeholder="请输入英文分类名称">
            </div>
            <div class="form-group">
                <label for="">
                    分类缩略图
                </label>
                <input type="file" name="img" id="img" class="form-control">
            </div>
            <div class="form-group">
                <label for="">
                    分类排序
                </label>
                <input type="text" name="order" id="order" class="form-control" placeholder="请输入排序序号">
            </div>
            <input type="submit" value="添加分类" class="btn btn-primary">
            <input type="reset" value="重置表单" class="btn btn-danger">
        </form>
    </div>
</body>
</html>